﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;

/// <summary>
/// Summary description for nutrientDAO
/// </summary>
public class nutrientDAO : dataAccess
{
	public nutrientDAO()
	{

	}

    public DataSet get()
    {
        string sql = "select * from Nutrient";
        return getData(sql);
    }

    public void addNew(Nutrient nutrient)
    {
        String sql = String.Format("insert into Nutrient values ('{0}','{1}','{2}','{3}','{4}')",nutrient.Id,nutrient.Unit,nutrient.Name,nutrient.Type,nutrient.Code);
        executeQuery(sql);
    }
    public void delete(Nutrient nutrient)
    {
        String sql = "delete from Nutrient where NutrientID = '"+nutrient.Id+"'";
        executeQuery(sql);
    }
    public DataSet getNutrient(Nutrient nutrient)
    {
        string sql = "select * from Nutrient where NutrientID = '" + nutrient.Id + "'";
        return getData(sql);
    }
    public void update(Nutrient nutrient)
    {
        String sql = "update Nutrient set Unit = '"+nutrient.Unit+"', Name = '"+nutrient.Name+"',Type = '"+nutrient.Type+"',Code = '"+nutrient.Code+"' where NutrientID = '"+nutrient.Id+"'";
        executeQuery(sql);
    }
}